package com.wechat.core.controller;

import com.wechat.core.service.WxMediaService;
import com.wechat.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

/**
 *  素材管理
 * @author hgb
 * @date 2019/1/27
 * Email xhy18650@sina.com
 */
@RestController
public class WxMediaController {
    @Autowired
    WxMediaService wxMediaService;

    /**
     * 上传临时素材
     * @param file 素材
     * @param type 类型
     * @return
     */
    @RequestMapping("wxMediaController/uploadMedia")
    public R uploadMedia(@RequestParam("file") MultipartFile file,
                         @RequestParam("type")  String type){
        return wxMediaService.uploadMedia(file,type);
    }

    /**
     *  获取临时素材
     * @param media_id 素材id
     * @return
     */
    @RequestMapping("wxMediaController/getMedia")
    public R getMedia( @RequestParam("media_id")  String media_id){
        return wxMediaService.getMedia(media_id);
    }

    @RequestMapping("wxMediaController/addNewsMaterial")
    public R  addNewsMaterial(){
        return wxMediaService.addNewsMaterial(new HashMap<>());
    };
}
